package com.xx.springboot.service.impl;

import com.xx.springboot.entity.ResponseBo;
import com.xx.springboot.entity.Syslog;
import com.xx.springboot.mapper.SyslogMapper;
import com.xx.springboot.service.ISyslogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaoxiunique
 * @since 2018-11-05
 */
@Service
public class SyslogServiceImpl extends ServiceImpl<SyslogMapper, Syslog> implements ISyslogService {

    @Autowired
    private SyslogMapper syslogMapper;

    @Override
    public ResponseBo getSysLogList(Integer pageNo, Integer pageSize) {
        Map<String, Object> map = new HashMap<>();

        try {
            List<Syslog> sysLogList = syslogMapper.getSysLogList(pageNo, pageSize);
            int count = syslogMapper.getSysLogListCount(pageNo, pageSize);
            map.put("list", sysLogList);
            map.put("count", count);
            return ResponseBo.ok(map);

        }catch (Exception ex) {
            return ResponseBo.error(ex.toString());
        }
    }
}
